package javaStudy.线程.线程优先级;

public class ThreadPriorityDemo {
    public static void main(String[] args) {
        //创建线程
        ThreadPriority tp1=new ThreadPriority();
        ThreadPriority tp2=new ThreadPriority();
        ThreadPriority tp3=new ThreadPriority();
        //设置线程名字
        tp1.setName("胡");
        tp2.setName("海");
        tp3.setName("霖");
        //返回线程优先级
        System.out.println(tp1.getPriority());
        System.out.println(tp2.getPriority());
        System.out.println(tp3.getPriority());
        //设置线程优先级，范围1-10，默认是5；数字越大，优先级越高，且代表的是抢占cup的可能性越高，并不绝对1优先
        tp1.setPriority(10);
        tp2.setPriority(5);
        tp3.setPriority(1);
        //执行线程
        tp1.start();
        tp2.start();
        tp3.start();
    }
}
